package cn.edu.nju.freshdelivery.model;

import java.sql.Time;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Transient;

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Seller entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "seller", catalog = "freshdelivery")
public class Seller implements java.io.Serializable {

	// Fields

	private Integer id;
	private String username;
	private String password;
	private String name;
	private String address;
	private String location;
	private Integer phone;
	private Double leastCost;
	private Time startTime;
	private Time endTime;
	private Boolean valid;
	private Set<Dish> dishs = new HashSet<Dish>(0);
	private Set<Order> orders = new HashSet<Order>(0);

	// Constructors

	/** default constructor */
	public Seller() {
	}

	/** minimal constructor */
	public Seller(String username, String password, String name,
			String address, Double leastCost, Time startTime, Time endTime,
			Boolean valid) {
		this.username = username;
		this.password = password;
		this.name = name;
		this.address = address;
		this.leastCost = leastCost;
		this.startTime = startTime;
		this.endTime = endTime;
		this.valid = valid;
	}

	/** full constructor */
	public Seller(String username, String password, String name,
			String address, String location, Integer phone, Double leastCost,
			Time startTime, Time endTime, Boolean valid, Set<Dish> dishs,
			Set<Order> orders) {
		this.username = username;
		this.password = password;
		this.name = name;
		this.address = address;
		this.location = location;
		this.phone = phone;
		this.leastCost = leastCost;
		this.startTime = startTime;
		this.endTime = endTime;
		this.valid = valid;
		this.dishs = dishs;
		this.orders = orders;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "username", nullable = false, length = 45)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "password", nullable = false, length = 45)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "name", nullable = false, length = 45)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "address", nullable = false, length = 65535)
	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name = "location", length = 65535)
	public String getLocation() {
		return this.location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	@Column(name = "phone")
	public Integer getPhone() {
		return this.phone;
	}

	public void setPhone(Integer phone) {
		this.phone = phone;
	}

	@Column(name = "leastCost", nullable = false, precision = 22, scale = 0)
	public Double getLeastCost() {
		return this.leastCost;
	}

	public void setLeastCost(Double leastCost) {
		this.leastCost = leastCost;
	}

	@Column(name = "startTime", nullable = false, length = 8)
	public Time getStartTime() {
		return this.startTime;
	}

	public void setStartTime(Time startTime) {
		this.startTime = startTime;
	}

	@Column(name = "endTime", nullable = false, length = 8)
	public Time getEndTime() {
		return this.endTime;
	}

	public void setEndTime(Time endTime) {
		this.endTime = endTime;
	}

	@Column(name = "valid", nullable = false)
	public Boolean getValid() {
		return this.valid;
	}

	public void setValid(Boolean valid) {
		this.valid = valid;
	}

	@Transient
//	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "seller")
	public Set<Dish> getDishs() {
		return this.dishs;
	}

	public void setDishs(Set<Dish> dishs) {
		this.dishs = dishs;
	}
	@Transient
//	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "seller")
	public Set<Order> getOrders() {
		return this.orders;
	}

	public void setOrders(Set<Order> orders) {
		this.orders = orders;
	}

}